#ifndef INFINITY_SERVICE_ENTITY_H
#	define INFINITY_SERVICE_ENTITY_H

#include "service.h"
#include "entity.h"

namespace infinity {

class ServiceEntity
:	public Service
{
public : //! @name Constants
	//! @{
	static const ServiceKey Key;
	//! @}

public : //! @name Types definitions
	//! @{
	typedef Service super;
	//! @}

public : //! @name Commands
	//! @{
	template< class T >
	T* spawnEntity(const std::string& name);

	template< class T >
	T* spawnEntityFromArchetype(const std::string& name, const EntityId& achetypeId);

	void condemnEntity(Entity* entity);

	inline std::vector< Entity * >& getLivingEntity();
	//! @}

public : //! @name Service Commands
	//! @{
	virtual void renderDebug();
	//! @}

protected : //! @name Service callbacks
	//! @{
	virtual State onInitializeSimulation();
	virtual void onUpdateSimulation(dw::float32 deltaT);
	virtual State onTerminateSimulation();
	
	virtual void onUpdateMedia(dw::float32 deltaT);
	//! @}

private : //! @name Construction & Destruction
	//! @{
	friend class ServiceManager;

	ServiceEntity();
	virtual ~ServiceEntity();
	//! @}

private : //! @name Types definitions
	//! @{
	typedef std::vector< Entity* > EntitiesCollection;
	//! @}

private : //! @name Data
	//! @{
	EntitiesCollection m_borningEntities;
	EntitiesCollection m_entities;
	EntitiesCollection m_condemnedEntities;
	EntityId m_nextId;
	//! @}
};

} // namespace infinity

#include "serviceentity.inl"

#endif // !INFINITY_SERVICE_ENTITY_H
